﻿using Abp.Domain.Entities;
using SOEI.Solution.DomainEntities.Parameters;
using SOEI.Solution.DomainEntities.RegulatoryMange;
using SOEI.Solution.Integratedes.Organization;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using static SOEI.Solution.AppCoreConst;

namespace SOEI.Solution.DomainEntities.ContractManagement
{
    [Table("CLFWQ_MMHT")]
    public class ContractSummary : Entity<string>
    {
        #region -------------------------------------------------实体属性---------------------------------------------- 

        /// <summary> 合同登记号
        /// </summary>
        [Column("HTDJH")]
        [MaxLength(EntityLength.Length10)]
        [StringLength(EntityLength.Length10)]
        public override string Id { get; set; }

        /// <summary> 合同登记号ID
        /// </summary>
        [Column("HTDJHID")]
        [MaxLength(EntityLength.Length10)]
        [StringLength(EntityLength.Length10)]
        public string ContractRegistrationId { get; set; }

        /// 房屋单价
        [Column("FWDJ")]
        public decimal? HouseUnitPrice { get; set; }

        /// 房屋总价
        [Column("FWZJ")]
        public decimal? HousePrice { get; set; }

        /// 合同份数
        [Column("HTFS")]
        public decimal? ContractCopies { get; set; }

        /// <summary> 经办人
        /// </summary>
        [Column("JBR")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string Transactor { get; set; }

        /// <summary> 合同状态代码
        /// </summary>
        [Column("HTZTDM")]
        [MaxLength(EntityLength.Length2)]
        [StringLength(EntityLength.Length2)]
        public string ContractStatusId { get; set; }

        /// <summary> 录入时间
        /// </summary>
        [Column("LRSJ", TypeName = "date")]
        public DateTime? CreationTime { get; set; }

        /// <summary> 提交时间
        /// </summary>
        [Column("TJSJ", TypeName = "date")]
        public DateTime? CommitTime { get; set; }

        /// <summary> 审核时间
        /// </summary>
        [Column("SHSJ", TypeName = "date")]
        public DateTime? VerifyTime { get; set; }

        /// <summary> 房屋编号
        /// </summary>
        [Column("FWBH")]
        [MaxLength(EntityLength.Length10)]
        [StringLength(EntityLength.Length10)]
        public string HouseId { get; set; }

        /// <summary> 代理人证件号码
        /// </summary>
        [Column("DLRZJHM")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string AgentIdNumber { get; set; }

        /// <summary> 代理人名称
        /// </summary>
        [Column("DLRMC")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string AgentName { get; set; }

        /// <summary> 合同类型代码
        /// </summary>
        [Column("HTLXDM")]
        [MaxLength(EntityLength.Length2)]
        [StringLength(EntityLength.Length2)]
        public string ContractTypeCode { get; set; }

        /// <summary> 产权证号
        /// </summary>
        [Column("CQZH")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string CertificateName { get; set; }

        /// <summary> 产权证编号
        /// </summary>
        [Column("CQZBH")]
        [MaxLength(EntityLength.Length72)]
        [StringLength(EntityLength.Length72)]
        public string CertificateCode { get; set; }

        /// <summary>
        /// 经纪机构编号
        /// </summary>
        [Column("JJJGBH")]
        [MaxLength(EntityLength.Length10)]
        [StringLength(EntityLength.Length10)]
        public string BrokerageInstitutionId { get; set; }

        /// <summary> 经纪机构名称
        /// </summary>
        [Column("JJJGMC")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string BrokerageInstitutionName { get; set; }

        /// <summary> 建筑面积
        /// </summary>
        [Column("JZMJ")]
        public decimal? BuildingArea { get; set; }

        /// <summary> 甲方密码
        /// </summary>
        [Column("JFMM")]
        [MaxLength(EntityLength.Length10)]
        [StringLength(EntityLength.Length10)]
        public string PartyAPassword { get; set; }

        /// <summary> 乙方密码
        /// </summary>
        [Column("YFMM")]
        [MaxLength(EntityLength.Length10)]
        [StringLength(EntityLength.Length10)]
        public string PartyBPassword { get; set; }

        /// <summary> 套内面积
        /// </summary>
        [Column("TNMJ")]
        public decimal? RoomBuildingArea { get; set; }

        /// <summary> 分摊面积
        /// </summary>
        [Column("FTMJ")]
        public decimal? ContributionArea { get; set; }

        /// <summary> 合同份数
        /// </summary>
        [Column("HTYS")]
        public decimal? ContractCount { get; set; }

        /// <summary> 经办人名称
        /// </summary>
        [Column("JBRMC")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string AttentionLine { get; set; }

        /// <summary> 房屋用途
        /// </summary>
        [Column("FWYT")]
        [MaxLength(EntityLength.Length20)]
        [StringLength(EntityLength.Length20)]
        public string HouseUsage { get; set; }

        /// <summary> 房屋性质
        /// </summary>
        [Column("FWXZ")]
        [MaxLength(EntityLength.Length20)]
        [StringLength(EntityLength.Length20)]
        public string HouseProperty { get; set; }

        /// <summary> 合同签订平台，0为企业端，1为管理端
        /// </summary>
        [Column("XTPT")]
        [MaxLength(EntityLength.Length1)]
        [StringLength(EntityLength.Length1)]
        public string SystemPlatform { get; set; } = "0";

        /// <summary> 不带多单的产权证号
        /// </summary>
        [Column("CQZH2")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string CertificateName_2 { get; set; }

        /// <summary> 委托合同编号
        /// </summary>
        [Column("WTHTBH")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string EntrustmentContractId { get; set; }

        /// <summary> 合同办理状态代码
        /// </summary>
        [Column("HTBLZTDM")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string ContractHandlingStatusCode { get; set; }

        /// <summary> 单价
        /// </summary>
        [Column("DJ")]
        public decimal? UnitPrice { get; set; }

        /// <summary> 坐落信息
        /// </summary>
        [Column("ZLXX")]
        [MaxLength(EntityLength.Length500)]
        [StringLength(EntityLength.Length500)]
        public string LocatedInformation { get; set; }

        /// <summary> 付款方式代码
        /// </summary>
        [Column("FKFSDM")]
        [MaxLength(EntityLength.Length2)]
        [StringLength(EntityLength.Length2)]
        public string PaymentMethodCode { get; set; }

        /// <summary> 合同有效天数
        /// </summary>
        [Column("HTYXTS")]
        public decimal? ContractValidityDays { get; set; }

        /// <summary> 合同有效期
        /// </summary>
        [Column("HTYXQ")]
        [MaxLength(EntityLength.Length14)]
        [StringLength(EntityLength.Length14)]
        public string HTYXQ { get; set; }

        /// <summary> 截止日期，存到日 YYYY-MM-DD
        /// </summary>
        [Column("JZRQ", TypeName = "date")]
        public DateTime? PeriodTerminate { get; set; }

        /// <summary> 合同模型配置代码
        /// </summary>
        [Column("HTMXPZDM")]
        [MaxLength(EntityLength.Length2)]
        [StringLength(EntityLength.Length2)]
        public string ContractModelConfigCode { get; set; }

        /// <summary> 04（老版）、02（经纪版）、03（自行交易版）
        /// </summary>
        [Column("HTBS")]
        [MaxLength(EntityLength.Length2)]
        [StringLength(EntityLength.Length2)]
        public string ContractIdentification { get; set; }

        /// <summary> 出卖人
        /// </summary>
        [Column("CMR")]
        [MaxLength(EntityLength.Length4000)]
        [StringLength(EntityLength.Length4000)]
        public string Seller { get; set; }

        /// <summary> 受买方
        /// </summary>
        [Column("SMF")]
        [MaxLength(EntityLength.Length4000)]
        [StringLength(EntityLength.Length4000)]
        public string Buyer { get; set; }

        /// <summary> 出卖人证件号码
        /// </summary>
        [Column("CMR_ZJHM")]
        [MaxLength(EntityLength.Length4000)]
        [StringLength(EntityLength.Length4000)]
        public string SellerIdCardNumber { get; set; }

        /// <summary> 受买方证件号码
        /// </summary>
        [Column("SMF_ZJHM")]
        [MaxLength(EntityLength.Length4000)]
        [StringLength(EntityLength.Length4000)]
        public string BuyerIdCardNumber { get; set; }

        /// <summary> 是否抵押
        /// </summary>
        [Column("SFDY")]
        [MaxLength(EntityLength.Length2)]
        [StringLength(EntityLength.Length2)]
        public string IsMortgage { get; set; }

        /// <summary> 上报标识
        /// </summary>
        [Column("SBBZ")]
        public string SBBZ { get; set; } = "01";

        /// <summary> 是否复审 0：不需要 1：需要
        /// </summary>
        [Column("SFFS")]
        [MaxLength(EntityLength.Length1)]
        [StringLength(EntityLength.Length1)]
        public string IsNeedRecheck { get; set; } = "0";

        /// <summary> 复审机构编号
        /// </summary>
        [Column("FSJGBH")]
        [MaxLength(EntityLength.Length6)]
        [StringLength(EntityLength.Length6)]
        public string RecheckOrganizationId { get; set; }

        /// <summary> 复审机构名称
        /// </summary>
        [Column("FSJGMC")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string RecheckOrganizationName { get; set; }

        /// <summary> 复审人编号
        /// </summary>
        [Column("FSRBH")]
        [MaxLength(EntityLength.Length8)]
        [StringLength(EntityLength.Length8)]
        public string RecheckPeopleId { get; set; }

        /// <summary> 复审人名称
        /// </summary>
        [Column("FSRMC")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string RecheckPeopleName { get; set; }

        /// <summary> 复审时间
        /// </summary>
        [Column("FSSJ", TypeName = "date")]
        public DateTime? RecheckTime { get; set; }

        /// <summary> 合同归属机构编号
        /// </summary>
        [Column("HTGSJGBH")]
        [MaxLength(EntityLength.Length10)]
        [StringLength(EntityLength.Length10)]
        public string ContractOwnerOrganizationId { get; set; }

        /// <summary> 不动产权证标识码
        /// </summary>
        [Column("BSM_BDCQZ")]
        [MaxLength(EntityLength.Length100)]
        [StringLength(EntityLength.Length100)]
        public string ImmovablesWarrantIdCode { get; set; }

        #endregion

        #region -------------------------------------------------用户定义---------------------------------------------- 
        /* 这里创建自己的代码 */

        /// <summary> 合同状态
        /// </summary>
        [NotMapped]
        public virtual ContractStatus ContractStatus { get; set; }

        /// <summary> 合同正文
        /// </summary>
        [NotMapped]
        public virtual ICollection<ContractBody> ContractBodys { get; set; } = new List<ContractBody>();

        /// <summary>经纪机构
        /// </summary>
        [NotMapped]
        public OEconomyOrgani oEconomyOrgani { get; set; }

        /// <summary>产权证
        /// </summary>
        [NotMapped]
        public PropertyCard PropertyCard { get; set; }

        [NotMapped]
        public Parameter HouseUsageParam { get; set; }

        #endregion

        #region -------------------------------------------------导航属性---------------------------------------------- 

        #endregion

    }
}
